'\" te
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH SCTP_GETPADDRS 3SOCKET "Jan 23, 2008"
.SH NAME
sctp_getpaddrs, sctp_freepaddrs \- returns all peer addresses on an SCTP
association
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lsocket\fR \fB -lnsl \fR \fB -lsctp \fR [ \fIlibrary\fR... ]
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/sctp.h>

\fBint\fR \fBsctp_getpaddrs\fR(\fBint\fR \fIsock\fR, \fBsctp_assoc_t\fR \fIid\fR, \fBvoid **\fR\fIaddrs\fR);
.fi

.LP
.nf
\fBvoid\fR \fBsctp_freepaddrs\fR(\fBvoid *\fR\fIaddrs\fR);
.fi

.SH DESCRIPTION
.LP
The \fBsctp_getpaddrs()\fR queries the peer addresses in an SCTP association.
The \fBsctp_freepaddrs()\fR function releases resources that are allocated to
hold the addresses.
.sp
.LP
The \fBsctp_getpaddrs()\fR function returns all the peer addresses in the SCTP
association identified by \fIsock\fR. On completion \fIaddrs\fR points to a
dynamically allocated array of \fBsockaddr_in\fR structures for an Internet
Protocol (IPv4) socket or an array of \fBsockaddr_in6\fR structures for an
Internet Protocol Version 6 (IPv6) socket. The \fIaddrs\fR parameter must not
be \fINULL\fR. For an IPv4 SCTP socket, the addresses returned in the
\fBsockaddr_in\fR structures are IPv4 addresses. For an IPv6 SCTP socket, the
addresses in the \fBsockaddr_in6\fR structures can be IPv6 addresses or
IPv4-mapped IPv6 addresses.
.sp
.LP
If \fIsock\fR is a one-to-many style SCTP socket, \fIid\fR specifies the
association of interest. If \fIsock\fR is a one-to-one style SCTP socket,
\fIid\fR is ignored.
.sp
.LP
The \fBsctp_freepaddrs()\fR function frees the resources allocated by
\fBsctp_getpaddrs()\fR. The \fIaddrs\fR parameter is the array of addresses
allocated by \fBsctp_getpaddrs()\fR.
.SH RETURN VALUES
.LP
Upon successful completion, the \fBsctp_getpaddrs()\fR function returns the
number of addresses in the \fIaddrs\fR array. Otherwise, the function returns
\fB-1\fR and sets \fBerrno\fR to indicate the error.
.SH ERRORS
.LP
The \fBsctp_getpaddrs()\fR succeeds unless one of the following conditions
exist.
.sp
.ne 2
.na
\fB\fBEBADF\fR\fR
.ad
.RS 12n
The \fIsock\fR argument is an invalid file descriptor.
.RE

.sp
.ne 2
.na
\fB\fBENOTSOCK\fR\fR
.ad
.RS 12n
The \fIsock\fR argument is not a socket.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 12n
The \fIaddrs\fR argument is \fINULL\fR.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 12n
The \fIid\fR argument is an invalid association identifier for a one-to-many
style STP socket.
.RE

.sp
.ne 2
.na
\fB\fBENOTCONN\fR\fR
.ad
.RS 12n
The specified socket is not connected.
.RE

.SH ATTRIBUTES
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
MT-Level	Safe
.TE

.SH SEE ALSO
.LP
.BR in.h (3HEAD),
.BR libsctp (3LIB),
.BR bind (3SOCKET),
.BR sctp_freeladdrs (3SOCKET),
.BR sctp_getladdrs (3SOCKET),
.BR sockaddr (3SOCKET),
.BR socket (3SOCKET),
.BR inet (4P),
.BR inet6 (4P),
.BR ip (4P),
.BR ip6 (4P),
.BR sctp (4P),
.BR attributes (7)
